<?php

class Category extends Controller {

	function Category()
	{
		parent::Controller();
		if(!$this->session->userdata('logged_in')) {
			redirect('app/login');
		}
		$this->load->model('Category_model');
	}
	
	function index()
	{
		$this->main();
	}
	
	function main(){
		$data['all'] = $this->Category_model->get_all();
		$this->load->view('category/index.php',$data);
	}
	
	function create(){
		$this->load->view('category/create.php');
	}
	
	function insert()
	{
		if(!$this->Category_model->insert()){
			$this->session->set_flashdata('error', TRUE);
		}
		redirect('category');
	}
}
?>